﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using Store;
using Factory;
using Logger;

namespace ProgramGUI
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            CenterToScreen();
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            bouquet = FlowerFactory.CreateBouquet();
            logger = LoggerFactory.CreateLogger();

            logger.Log("Начало работы с программой.");

            listFlowers.Items.Add(FlowerFactory.CreateFlower(0));
            listFlowers.Items.Add(FlowerFactory.CreateFlower(1));
            listFlowers.Items.Add(FlowerFactory.CreateFlower(2));

            logger.Log("Добавлены доступные цветы.");
        }

        private void buttonAdd_Click(object sender, EventArgs e)
        {

                bouquet.addFlower(listFlowers.SelectedItem);
                logger.Log("Цветок '" + listBouquet.GetItemText(listFlowers.SelectedItem) + "' добавлен в букет.");

                listBouquet.Items.Add(listFlowers.SelectedItem);

                valueCost.Text = bouquet.getTotalCost().ToString() + " руб.";

        }

        private void buttonDelete_Click(object sender, EventArgs e)
        {

                bouquet.removeFlower(listBouquet.SelectedIndex);
                //logger.Log("Цветок '" + listBouquet.GetItemText(listBouquet.SelectedItem) + "' удален из букета.");

                listBouquet.Items.Remove(listBouquet.SelectedItem);

                valueCost.Text = bouquet.getTotalCost().ToString() + " руб.";
 
    }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            logger.Log("Конец работы с программой.");
        }
    }
}
